/*class Touchpad implements Observer {
  
  public int touchState;
  public float x0, y0;
  public float xValue, yValue;
  public float xPosition, yPosition;
  
  private static final int MAX_FINGER_BLOBS = 20;

  private int width, height;
  
  
  TouchpadObservable tpo;
  
  Finger blobs[] = new Finger[MAX_FINGER_BLOBS];
  
  

  public Touchpad(int width, int height) {	
    this.width = width;
    this.height=height;
    this.x0 = 0;
    this.y0 = 0;
    this.touchState = 0;
    tpo = TouchpadObservable.getInstance();
    tpo.addObserver(this);
  }

  // Multitouch update event 
  public void update( Observable obj, Object arg ) {
    // The event 'arg' is of type: com.alderstone.multitouch.mac.touchpad.Finger
    Finger f = (Finger) arg;
    int id = f.getID();
    if (id <= MAX_FINGER_BLOBS)
      blobs[id-1]= f;
  }	

  public void update() {}
  
  public int getTouch() {
    
    float x = 0;
    float y = 0;
    int n_touch = 0;

    for (int i=0; i<MAX_FINGER_BLOBS;i++) {
      Finger f = blobs[i];
      if (f != null && f.getState() == FingerState.PRESSED) {
        n_touch++;
        x += f.getX();
        y += f.getY();
      }
    }
    
    if (n_touch > 0) {
      xPosition = x/n_touch;
      yPosition = y/n_touch;
    }
    
      switch (n_touch) {
      case 0: {
        touchState = 0;
        break;
      }
      case 1: {
        
        switch (touchState) {
          case 0: {
            x0 = xPosition;
            y0 = yPosition;
            yValue = 0;
            xValue = 0;
            touchState = 1;
            break;
          }
          case 1: {
            yValue = yPosition - y0;
            xValue = xPosition - x0;
            break;
          }
        }
        
        break;
      }
      case 2: {
        
        switch (touchState) {
          case 0: {
            x0 = xPosition;
            y0 = yPosition;
            yValue = 0;
            xValue = 0;
            touchState = 2;
            break;
          }
          case 2: {
            float dy = yPosition - y0;
            float dx = xPosition - x0;
            if ((abs(dy) > abs(dx)) && abs(dy) > 0.05) {
              touchState = 3;
              y0 += dy;
            } else if ((abs(dx) > abs(dy)) && abs(dx) > 0.05) {
              touchState = 4;
              x0 += dx;
            }
            break;
          }
          case 3: {
            yValue = yPosition - y0;
            break;
          }
          case 4: {
            xValue = xPosition - x0;
            break;
          }
        }        
        break;
      }
    }
    return n_touch;
  }

  public void draw() {

    for (int i=0; i<MAX_FINGER_BLOBS;i++) {
      Finger f = blobs[i];
      if (f != null && f.getState() == FingerState.PRESSED) {

        int x     = (int) (width  * (f.getX()));
        int y     = (int) (height * (1-f.getY()));
        int xsize = (int) (10*f.getSize() * (f.getMajorAxis()/2));
        int ysize = (int) (10*f.getSize() * (f.getMinorAxis()/2));
        int ang   = f.getAngle();

        
        pushMatrix();
        translate(x-xsize/2, y-ysize/2);
        pushMatrix();
        rotate(radians(-ang));  // convert degrees to radians
        fill(255);
        ellipse(0,0,xsize,ysize);
        popMatrix();
        fill(255,0,0);
        text(""+i,0,0);
        popMatrix();
      }
    }
  }
}
*/

